#include "Menu.hh"
#include "Utility.hh"
#include <string>

using namespace Utility;
Menu::Menu(Bank& bank) : bank(bank) {}
Menu::~Menu() {}
Menu::Menu(const Menu& other) : bank(other.bank) {}
Menu& Menu::operator=(const Menu& other) {
    if (this != &other) {
        bank = other.bank;
    }
    return *this;
}
void Menu::run() {
    while (true) {
        std::cout << "===== Banking System =====\n";
        std::cout << "1. Register new customer\n";
        std::cout << "2. Access customer accounts\n";
        std::cout << "3. Display all bank accounts\n";
        std::cout << "4. Transaction reports\n";
        std::cout << "5. Exit\n";
        std::cout << "Please choose: ";

        int choice;
        std::cin >> choice;

        switch (choice) {
            case 1: {
                clearScreen();
                std::cout << "===== Register New Customer =====\n";
                std::string name;
                std::cout << "Enter customer name: ";
                std::getline(std::cin,name);
                bank.addCustomer(name);
                break;
            }
            case 2: {
                clearScreen();
                std::cout << "===== Access Customer Accounts =====\n";
                std::string name;
                std::cout << "Enter customer name: ";
                std::getline(std::cin, name);
                Customer* customer = bank.findCustomer(name);
                if (customer) {
                    customer->accessAccounts();
                } else {
                    std::cout << "Customer not found.\n";
                }
                break;
            }
            case 3: {
                clearScreen();
                std::cout << "===== Display All Bank Accounts =====\n";
                bank.displayAllAccounts();
                break;
            }
            case 4: {
                clearScreen();
                std::cout << "===== Transaction Reports =====\n";
                bank.generateReport();
                break;
            }
            case 5: {
                return;
            }
            default: {
                std::cout << "Invalid choice. Please try again.\n";
            }
        }
    }
}